package com.gitee.jwt.controller;

import com.gitee.jwt.JWTUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/login")
public class LoginController {

    @GetMapping("/in")
    public String login(
            @RequestParam String account,
            @RequestParam String password,
            HttpServletRequest request
    ) throws Exception {
        /**
         * 处理登录 ，根据用户名生成token 登录成功返回token
         */
        return JWTUtils.sign(account);
    }

    @GetMapping("/out")
    public String loginError(
    ) throws Exception {
        return "loginOut";
    }
}
